package com.hu.zhcc.shiro.service.xsf.impl;

import com.hu.zhcc.shiro.dao.xsf.ChatInfoMapper;
import com.hu.zhcc.shiro.entity.bo.base.User;
import com.hu.zhcc.shiro.entity.lgx.TMember;
import com.hu.zhcc.shiro.entity.xsf.pojo.ChatInfo;
import com.hu.zhcc.shiro.service.xsf.ChatInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class ChatInfoImpl implements ChatInfoService {
    @Autowired
    private ChatInfoMapper chatInfoMapper;

    @Override
    public int insertSelective(ChatInfo record) {
        record.setDirection(1);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");
        record.setCreatetime(simpleDateFormat.format(new Date()));
        record.setState(0);

        record.setSysUserId(1);
        return chatInfoMapper.insertSelective(record);
    }

    @Override
    public ChatInfo selectByPrimaryKey(Integer id) {
        return chatInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<ChatInfo> queryInfoBySysId( Integer sysUserId) {
//        User user = (User)session.getAttribute("sysUser");
        return chatInfoMapper.queryInfoBySysId(1);
    }

    @Override
    public List<ChatInfo> queryInfoByMemberId(Integer memberId, Integer sysUserId) {
        return chatInfoMapper.queryInfoByMemberId(memberId, sysUserId);
    }

    @Override
    public int updateByPrimaryKeySelective(ChatInfo record) {
        return 0;
    }
}
